/** @jsxImportSource @emotion/react */
import * as React from "react";
import { OriginalViewProps, } from "../../common/base";
import {config设备概况, EntranceSetup} from "./orcBase";
import { createItem, } from "../../common/eHelper";
import { useRecordListSubr} from "../../hook/useRecordListSub";
import {PropertySolidify} from "../EditorFeature";
import {IPipingUnitEntity} from "../../../comp/ChoosePipingUnits";
import {ConclusionSteelFi, } from "./Conclusion";
import {ConclusionSurvey} from "../../gas/plastics/Conclusion";
import {ProjectR} from "../../gas/utilityNj/ProjectR";
import {Explanatory} from "../steelThDj/Explanatory";

//记录存储附加兼容 公用管道年度检查记录    #报告==》记录
//参数 @om =ture: 只是在记录目录存在的，但是在正式报告目录却不显示的。 @na表示在两个目录页都不存在。
export const Projects记录=[
    {name:'定期检验结论报告',do:true,ha:'Conclusion'},
    {name:'定期检验报告综述', ha:'Explanatory', },
    {name:'管道特性表',do:true,  ha:'Characteristics'},
];

const recordPrintList =[
    createItem('Entrance', <EntranceSetup/>),
    createItem('ProjectList', <ProjectR config={Projects记录} label={'记录目录页'}/>),
    createItem('Survey', <ConclusionSurvey config={config设备概况} label={'定期检验结论报告-设备概况'}/>),
    createItem('Conclusion', <ConclusionSteelFi label={'定期检验结论报告-下结论'}/>),
    createItem('Explanatory', <Explanatory label={'定期检验报告综述'} />),

    createItem('Solidify', <PropertySolidify label={'管道特性表-管理器'} filterCB={modelToRepData}/>),
    createItem('_Controller',  <></>),
];

//特性表不一样就得改了：
//针对这个模板CharacteristRow()需要显示字段： 从Relay模型获取报告才需要的字段：svp pa只保存有用到的字段：但是PropertySolidify必须提取全面useLazyLoadQuery<typeof EditorFeatureQuery>。
function modelToRepData(pipe:IPipingUnitEntity){
  const {id,crDate,name,code,leng,level,start,stop,lay,rno,svp,pa,proj,insd,used,thik,desu,insu,dia }=pipe as any;
  const {材料,设压,设温, 腐蚀, }=svp;
  const {工介,工压,工温,试压,防腐材,沥青级,防腐厚}=pa;
  //节约存储; 后端报告中：不需要存储usue{id,name}；
  return {
    id,crDate, name,code,leng,level,start,stop,lay,rno,proj,insd,used,thik,desu,insu,dia,
    svp:{材料,设压,设温, 腐蚀, },
    pa:{工介,工压,工温,试压,防腐材,沥青级,防腐厚}
  };
}

export const OriginalView=
  React.forwardRef((
    { action: modAction,  verId, repId='', rep}
    :OriginalViewProps, ref
  ) => {
    const {list}=useRecordListSubr(ref,rep,recordPrintList,modAction,verId);
    return <React.Fragment>
      {list}
    </React.Fragment>;
  } );
